

#include "WProgram.h"
void setup();
void loop();
int val;
int val56;
void setup() 
{ 

TCCR0B = TCCR0B & 0b11111000 | 0x05;
TCCR1B = TCCR1B & 0b11111000 | 0x04;
TCCR2B = TCCR2B & 0b11111000 | 0x06;


  Serial.begin(9600);
} 
 
void loop() 
{ 
  
  int ar=analogRead(2);
  
  val = ar/1023.0*60+1;
  val56 = ar/1023.0*+1;
  
  //TCCR0B
  analogWrite(5,val56);
  analogWrite(6,val56);
  
  //TCCR1B
  analogWrite(9, val);
  analogWrite(10, val);
  //TCCR2B
  analogWrite(11, val);
  analogWrite(3, val);

  Serial.println(val/61.0*180);
//  TCCR1B = TCCR1B & 0b11111000 | 0x05;
 // analogWrite(10, 1);
  
  /*  //test if it works
  digitalWrite(13,HIGH)
  delayMicroseconds(500);
  digitalWrite(13, LOW)
  delayMicroseconds(7500);
  */
  
    /*  //test if it works
  digitalWrite(13,HIGH)
  delayMicroseconds(500);
  digitalWrite(13, LOW)
  delayMicroseconds(1500);
  */
}




/*
Pins 5 and 6: controlled by Timer 0

Setting 	Divisor 	Frequency
0x01 	 	1 	 	62500
0x02  		8 	 	7812.5
0x03  		64 	 	976.5625
0x04 	 	256 	 	244.140625
0x05 	 	1024 	 	61.03515625    16.39ms

TCCR0B = TCCR0B & 0b11111000 | <setting>;


Pins 9 and 10: controlled by timer 1

Setting 	Divisor 	Frequency
0x01 	 	1 	 	31250
0x02 	 	8 	 	3906.25
0x03  		64 	 	488.28125
0x04  		256 	 	122.0703125   8.196ms
0x05 	 	1024 	 	30.517578125  32.769ms

TCCR1B = TCCR1B & 0b11111000 | <setting>;


Pins 11 and 3: controlled by timer 2

Setting 	Divisor 	Frequency
0x01 	 	1  		31250
0x02 	 	8 	 	3906.25
0x03  		32  		976.5625
0x04 	 	64 	 	488.28125
0x05 	 	128  		244.140625
0x06  		256  		122.0703125       8.196ms
0x07 	 	1024  		30.517578125      32.769ms
*/


int main(void)
{
	init();

	setup();
    
	for (;;)
		loop();
        
	return 0;
}

